{% extends "admin/base.html" %}

{% block stylesheets %}
	<link rel="stylesheet" type="text/css" href="{{ url_for('views.themes', theme='admin', path='css/codemirror.css') }}">
{% endblock %}

{% block content %}
<div class="jumbotron">
	<div class="container">
		<h1>配置</h1>
	</div>
</div>
<div class="container">
	<div class="row">
		<div class="col-md-3">
			<ul id="config-sidebar" class="nav nav-pills flex-column">

				<li class="nav-item">
					<a class="nav-link rounded-0 py-1 active" href="#general" role="tab" data-toggle="tab">
						<i class="fa fa-gear action-icon"></i>常规
					</a>
				</li>
				<!-- Appearance -->
				<small class="section-title">外观</small>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#logo" role="tab" data-toggle="tab">
						<i class="fa fa-signature action-icon"></i>图标
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#theme" role="tab" data-toggle="tab">
						<i class="fa fa-brush action-icon"></i>主题
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#localization" role="tab" data-toggle="tab">
						<i class="fa fa-language action-icon"></i>本地化
					</a>
				</li>
				<!-- Access -->
				<small class="section-title">比赛设置</small>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#visibility" role="tab" data-toggle="tab">
						<i class="fa fa-eye action-icon"></i>可见性
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#ctftime" role="tab" data-toggle="tab">
						<i class="fa fa-stopwatch action-icon"></i>开始和结束时间
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#pause" role="tab" data-toggle="tab">
						<i class="fa fa-pause action-icon"></i>暂停
					</a>
				</li>

				<!-- Users -->
				<small class="section-title">用户</small>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#accounts" role="tab" data-toggle="tab">
						<i class="fa fa-users action-icon"></i>账户
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#brackets" role="tab" data-toggle="tab">
						<i class="fa fa-chart-line action-icon"></i>计分板分组
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#fields" role="tab" data-toggle="tab">
						<i class="fa fa-fingerprint action-icon"></i>自定义字段
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#registration_code" role="tab" data-toggle="tab">
						<i class="fa fa-user-lock action-icon"></i>注册码
					</a>
				</li>

				<small class="section-title">备份</small>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#backup" role="tab" data-toggle="tab">
						<i class="fa fa-file-import action-icon"></i>导入和导出
					</a>
				</li>

				<!-- Security -->
				<small class="section-title">安全</small>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#sanitize" role="tab" data-toggle="tab">
						<i class="fa fa-shield-halved action-icon"></i>过滤
					</a>
				</li>

				<!-- Pages -->
				<small class="section-title">页面</small>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#legal" role="tab" data-toggle="tab">
						<i class="fa fa-scale-balanced action-icon"></i>Legal/法则
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#robots" role="tab" data-toggle="tab">
						<i class="fa fa-robot action-icon"></i>Robots.txt
					</a>
				</li>
				
				<!-- Integrations -->
				<small class="section-title">集成</small>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#email" role="tab" data-toggle="tab">
						<i class="fa fa-envelope action-icon"></i>邮件通知
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#social" role="tab" data-toggle="tab">
						<i class="fa fa-share-nodes action-icon"></i>社区分享
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1s" href="#mlc" role="tab" data-toggle="tab">
						<i class="fa fa-network-wired action-icon"></i>MajorLeagueCyber
					</a>
				</li>
				
				<!-- Plugins -->
				{% set plugins = get_configurable_plugins() %}
				{% if plugins %}
					<small class="section-title">Plugins</small>
					{% for plugin in plugins %}
						{% if plugin.config %}
							<li class="nav-item">
								<a class="nav-link rounded-0 py-1" href="#plugin_{{loop.index}}" role="tab" data-toggle="tab">
									<i class="fa-solid fa-puzzle-piece action-icon"></i>{{ plugin.name }}
								</a>
							</li>
						{% elif plugin.route %}
							<li class="nav-item">
								<a class="nav-link rounded-0 py-1" href="{{ plugin.route }}" target="_blank">
									<i class="fa-solid fa-puzzle-piece action-icon"></i>{{ plugin.name }} <i class="fa-solid fa-arrow-up-right-from-square fa-xs"></i>
								</a>
							</li>
						{% endif %}
					{% endfor %}
				{% endif %}

				<!-- Reset -->
				<small class="section-title">危险区域</small>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="#usermode" role="tab" data-toggle="tab">
						<i class="fa fa-people-arrows action-icon"></i>用户模式
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link rounded-0 py-1" href="{{ url_for('admin.reset') }}" role="tab">
						<i class="fa fa-trash-can action-icon"></i>！重置！
					</a>
				</li>
			</ul>
		</div>
		<div class="col-md-9">
			{% for error in errors %}
				<div class="alert alert-danger alert-dismissable" role="alert">
					<span class="sr-only">Error:</span>
					{{ error }}
					<button type="button" class="close" data-dismiss="alert" aria-label="Close">
						<span aria-hidden="true">×</span>
					</button>
				</div>
			{% endfor %}

			<div class="tab-content">
				{% include "admin/configs/general.html" %}

				<!-- Appearance -->

				{% include "admin/configs/logo.html" %}

				{% include "admin/configs/theme.html" %}

				{% include "admin/configs/localization.html" %}

				<!-- Access -->

				{% include "admin/configs/visibility.html" %}

				{% include "admin/configs/time.html" %}

				{% include "admin/configs/pause.html" %}

				<!-- Users -->

				{% include "admin/configs/accounts.html" %}

				{% include "admin/configs/usermode.html" %}

				{% include "admin/configs/brackets.html" %}

				{% include "admin/configs/fields.html" %}

				{% include "admin/configs/registration_code.html" %}

				<!-- Security -->

				{% include "admin/configs/backup.html" %}

				{% include "admin/configs/sanitize.html" %}

				<!-- Pages -->

				{% include "admin/configs/legal.html" %}

				{% include "admin/configs/robots.html" %}

				<!-- Integrations -->

				{% include "admin/configs/email.html" %}

				{% include "admin/configs/social.html" %}

				{% include "admin/configs/mlc.html" %}

				<!-- Plugins -->
				
				{% if plugins %}
					{% for plugin in plugins %}
						{% if plugin.config %}
							<div role="tabpanel" class="tab-pane config-section" id="plugin_{{loop.index}}">
								{% include plugin.config %}
							</div>
						{% endif %}
					{% endfor %}
				{% endif %}
				<!-- Danger zone -->
				<!-- reset.html is top-level so no need to include -->
			</div>
		</div>
	</div>
</div>
{% endblock %}

{% block scripts %}
{% endblock %}

{% block entrypoint %}
	{{ Assets.js("assets/js/pages/configs.js", theme="admin") }}
{% endblock %}
